<template>
  <window class="m-progress-detail am-form-group" ref="win" title="绑定学员">
    <div class="am-form-group am-u-lg-12 add-bing-student">
        <el-form>
            <div class="am-u-sm-12 am-fl el-form-item">
                <label class="am-u-sm-3 am-form-label">
                    <span class="am-text-danger am-margin-right-xs am-text-xs"></span>学员:
                </label>
                <div class="am-u-sm-9 am-fl form-last-left form-last-input">
                    <el-input v-model="userInfo.studentName" size="small"  placeholder="请输入学员" ></el-input>
                </div>
            </div>
            <div class="am-u-sm-12 am-fl el-form-item">
                <label class="am-u-sm-3 am-form-label">
                    <span class="am-text-danger am-margin-right-xs am-text-xs"></span>手机号:
                </label>
                <div class="am-u-sm-9 am-fl form-last-left form-last-input">
                    <el-input v-model="userInfo.phoneNo" size="small"  placeholder="请输入手机号" ></el-input>
                </div>
            </div>
            <div class="am-form-group save-btn" style="text-align: center">
                <button type="button" size="big" class="am-btn am-btn-primary" @click="saveStudentBing">保存</button>
            </div>
        </el-form> 
    </div>
  </window>
</template>

<script>
  import io from '../../lib/io'
  import {regLevels} from '../../lib/global'
  import moment from 'moment'

  export default{
    components: {},
    data: function () {
      return {
        userId:'',
        userInfo: {
            studentName:'',
            phoneNo:"",
        },
      }
    },
    created () {
    },
    watch: {

    },
    computed: {
    },
    methods:{
        handleConfirm () {
        // this.$refs.form.validate((valid) => {
        //   if (valid) {
        //       coonsole.log(valid)
        //   } else {
        //     console.log('error submit!!')
        //     return false
        //   }
        // })
    
        },
        saveStudentBing(){
            let param = {
                userId:this.userId,
                studentName:this.userInfo.studentName,
                studentPhoneNo:this.userInfo.phoneNo,
            }
            if(!param.studentName){
                this.$alert("请输入学员姓名")
                return false
            }
            if(!param.studentPhoneNo){
                this.$alert("请输入学员电话")
                return false
            }
            io.post(io.bindStudent,param,(ret)=>{
                if(ret.success){
                    this.$refs.win.close()
                    this.$parent.customerBindStudentList()
                }else{
                    this.$alert(ret.desc)
                }
            })
        },
        handleCancel () {
            this.$refs.win.close()
        },
        show:function(){
            this.$refs.win.show( { width : 800 } )
        
        }
    }
}

</script>
<style lang="less" scoped>
  .m-progress-detail {
    .el-form {
        width: 550px;
        margin: 0 auto;
        text-align: left;
        margin-top: 30px;
        .el-select, .el-date-editor.el-input {
        width: 250px;
        }
        .am-form-label{
          margin-top:5px;
        
        }
        .form-last-input{
            float:left;
        }
    }
  }
</style>
<style lang="less">
    .add-bing-student{
        
        .form-last-input{
            float:left;
        }
    }
</style>

